     use Time::HiRes qw( sleep );

     use MCE::Flow;
     use MCE::Queue;

     my $q = MCE::Queue->new( await => 1, fast => 1 );
     my ( $producers, $consumers ) = ( 1, 8 );

     mce_flow {
        task_name   => [ 'producer', 'consumer' ],
        max_workers => [ $producers, $consumers ],
     },
     sub {
        ## producer
        for my $item ( 1 .. 100 ) {
           $q->enqueue($item);

           ## blocks until the # of items pending reaches <= 10
           if ($item % 10 == 0) {
              MCE->say( 'pending: '.$q->pending() );
              $q->await(10);
           }
        }

        ## notify consumers no more work
        $q->end();

     },
     sub {
        ## consumers
        while (defined (my $next = $q->dequeue())) {
           MCE->say( MCE->task_wid().': '.$next );
           sleep 0.100;
        }
     };